package com.yuezhu.constomview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yuezhu.R;

import butterknife.InjectView;

/**
 * Created by zhao on 2016/5/4.
 */
public class MyView extends LinearLayout {

    RelativeLayout layoutMyviewTop;
    TextView myview_accout, my_title, my_all, my_has, my_no, my_date;
    @InjectView(R.id.myview_head_img)
    ImageView myviewHeadImg;
    @InjectView(R.id.myview_head_name)
    TextView myviewHeadName;
    @InjectView(R.id.myview_head_nike)
    TextView myviewHeadNike;
    @InjectView(R.id.my_has)
    TextView myHas;
    @InjectView(R.id.my_no)
    TextView myNo;

    public MyView(Context context) {
        super(context);
        initView(context);
    }

    public MyView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public MyView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initView(context);
    }

    private void initView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.layout_my_view, this);
        layoutMyviewTop = (RelativeLayout) view.findViewById(R.id.layout_myview_top);
        myviewHeadImg = (ImageView) view.findViewById(R.id.myview_head_img);
        myviewHeadName = (TextView) view.findViewById(R.id.myview_head_name);
        myviewHeadNike = (TextView) view.findViewById(R.id.myview_head_nike);
        myviewHeadName.setText("张三");
        myviewHeadNike.setText("哈哈");
        myview_accout = (TextView) view.findViewById(R.id.myview_accout);
        myview_accout.setText("账户余额:300");
        my_title = (TextView) view.findViewById(R.id.my_title);
        my_title.setText("租客账单");
        my_date = (TextView) view.findViewById(R.id.my_date);
        my_date.setText("2016/5/4");
        my_all = (TextView) view.findViewById(R.id.my_all);
        my_has = (TextView) view.findViewById(R.id.my_has);
        my_no = (TextView) view.findViewById(R.id.my_no);

    }

    public void setMyViewListener(OnClickListener listener) {
        my_all.setOnClickListener(listener);
        my_has.setOnClickListener(listener);
        my_no.setOnClickListener(listener);
    }
}
